package algocasts;

public class P135_SingleNumberII {
    public int[] singleNumber(int[] nums) {
        int xor = 0, mask = 1;
        for (int num : nums) xor ^= num;
        while ((xor & mask) == 0) mask <<= 1;
        int x = 0, y = 0;
        for (int num : nums) {
            if ((num & mask) == 0) x ^= num;
            else y ^= num;
        }
        return new int[]{x, y};
    }
}
